package com.ruoyi.train.service.impl;

import com.ruoyi.common.core.redis.RedisCache;

import com.ruoyi.common.utils.SequenceUtil;
import com.ruoyi.common.utils.uuid.IdUtils;
import com.ruoyi.train.domain.Train;
import com.ruoyi.train.domain.TrainOwnTrainListVo;
import com.ruoyi.train.domain.TrainTotalExportVo;
import com.ruoyi.train.domain.TrainType;
import com.ruoyi.train.mapper.TrainMapper;
import com.ruoyi.train.service.ITrainService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class TrainServiceImpl implements ITrainService {
    @Autowired
    private TrainMapper trainMapper;

    @Autowired
    private RedisCache redisCache;

    @Autowired
    public RedisTemplate redisTemplate;

    @Override
    public Train selectTrainByTrainId(String trainId, Long userId) {
        return trainMapper.selectTrainByTrainId(trainId, userId);
    }

    @Override
    public List<Train> selectTrainList(Train train) {
        return trainMapper.selectTrainList(train);
    }

    @Override
    public int insertTrain(Train train) {
        train.setTrainId(IdUtils.serialNumber("P",redisCache,ITrainService.class));
        return trainMapper.insertTrain(train);
    }

    /**
     * 查询用印类型
     *
     * @return 用印类型集合
     */
    @Override
    public List<TrainType> queryTrainTypes() {
        return trainMapper.queryTrainType();
    }

    /**
     * 批量删除培训
     *
     * @param trainIds 需要删除的培训主键集合
     * @param userId   用户id
     * @return int 结果
     */
    @Override
    public int deleteTrainByTrainIds(String[] trainIds, Long userId) {
        return trainMapper.deleteTrainByTrainIds(trainIds, userId);
    }

    @Override
    public int masterApproval(Train train) {
        return trainMapper.masterApproval(train);
    }

    /**
     * 管理员查看个人培训记录
     * @param train 培训集合
     * @return 培训集合
     */
    @Override
    public List<Train> selectTrainByGroup(Train train){
        return trainMapper.selectTrainByGroup(train);
    };

    @Override
    public List<TrainOwnTrainListVo> selectOwnTrainList(Long userId) {
        return trainMapper.selectOwnTrainList(userId);
    }

    @Override
    public List<TrainTotalExportVo> selectList(String[] ids) {
        return trainMapper.selectList(ids);
    }

    @Override
    public List<TrainTotalExportVo> selectListAll() {
        return trainMapper.selectListAll();
    }

    @Override
    public List<String> getDept() {
        return trainMapper.getDept();
    }
}
